package com.sword.onlysword.web.controller.games;

import com.sword.onlysword.entity.Sudoku;
import com.sword.onlysword.service.games.SudokuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * com.sword.onlysword.web.controller.games.WebGamesController
 * Created by SwordLiu on 2018-02-03.
 */
@Controller
@RequestMapping("/games")
public class SudokuController {

    @Autowired
    private SudokuService sudokuService;

    /**
     * 数独游戏
     * @return 数独
     */
    @RequestMapping("/sudoku")
    public String sudoku(Model model, Sudoku sudoku) {
        model.addAttribute("sudoku", sudokuService.sudoku(sudoku));
        return "games/sudoku";
    }

    /**
     * 数独游戏上传积分
     * @return 积分上传结果 true or false
     */
    @RequestMapping("/sudoku/add")
    @ResponseBody
    public Object addSudokuScore(Sudoku sudoku){
        return sudokuService.sudokuScore(sudoku);
    }

}
